package transactionimplementation

import (
	DataBase "SoftwareEngineering/DataBase"
	"reflect"
	"time"
	ModelImplementation "SoftwareEngineering/ModelImplementation"
)

type TimeCardTransaction struct {
	itsDate  time.Time
	itsHours float64
	itsEmpId int
}

func (t *TimeCardTransaction) Execute() {
	e := DataBase.PayrollDatabase.GetUnionMember(t.itsEmpId)

	if e != nil {
		pc := e.GetClassification()

		if reflect.TypeOf(pc) == reflect.TypeOf(ModelImplementation.HourlyClassification{}) {
			hr := pc.(*ModelImplementation.HourlyClassification)
			sr := ModelImplementation.TimeCard(t.itsDate, t.itsHours)
			hr.AddTimeCard(sr)
		}
	}
}
